package com.westvalley.common.result;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class JsonResult {
	private boolean flag;
	private String msg;
	private Object result;
	
	public static JsonResult me(JSONObject result){
		return new JsonResult(result);
	}
	
	public static JsonResult me(JSONArray result){
		return new JsonResult(result);
	}
	
	public static JsonResult me(String msg){
		return new JsonResult(msg);
	}
	
	public static JsonResult me(Exception e){
		return new JsonResult(e);
	}
	
	public static JsonResult me(boolean flag,String msg,Object result){
		return new JsonResult(flag,msg,result);
	}
	
	private JsonResult(JSONObject result){
		this(true,null,result);
	}
	
	private JsonResult(JSONArray result){
		this(true,null,result);
	}
	
	private JsonResult(String msg){
		this(false,msg,null);
	}
	
	private JsonResult(Exception e){
		this(e.getMessage());
	}
	
	private JsonResult(boolean flag,String msg,Object result){
		this.flag = flag;
		this.msg = msg;
		this.result = result;
	}
	
	public boolean isFlag() {
		return flag;
	}
	public void setFlag(boolean flag) {
		this.flag = flag;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getResult() {
		return result;
	}
	public void setResult(Object result) {
		this.result = result;
	}
}
